<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>产品页</title>
    <link href="//cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.css" rel="stylesheet">
</head>
<body>
    <div class="container">
        ${requestScope.pages.data}
        <table class="table table-bordered table-hover table-condensed table-striped">
            <thead>
                <tr>
                    <th>序号</th>
                    <th>商品id</th>
                    <th>商品名称</th>
                    <th>商品单价</th>
                    <th>商品库存</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <c:forEach var="pro" items="${requestScope.pages.data}" varStatus="st">
                    <tr>
                        <td>${st.count} : ${st.index}</td>
                        <td>${pro.id}</td>
                        <td>${pro.name}</td>
                        <td>${pro.price}</td>
                        <td>${pro.count}</td>
                        <td><a href="#" class="btn btn-success"><b class="glyphicon glyphicon-shopping-cart"></b> 购买</a></td>
                    </tr>
                </c:forEach>
            </tbody>
            <tbody>
                <tr>
                    <td colspan="5" align="center">
                        <c:if test="${requestScope.pages.pageNum == 1}">
                            <span class="btn btn-default disabled ">首　页</span>
                            <span class="btn btn-default disabled ">上一页</span>
                        </c:if>
                        <c:if test="${requestScope.pages.pageNum != 1}">
                            <a class="btn btn-danger" href="pages.do?pageCount=3&pageNum=${requestScope.pages.pageNum - 1}">上一页</a>
                        </c:if>

                        <c:forEach var="num" begin="1" end="${requestScope.pages.totalPages}">
                            <c:if test="${requestScope.pages.pageNum == num}">
                                <span class="btn btn-default disabled ">${num}</span>
                            </c:if>
                            <c:if test="${requestScope.pages.pageNum != num}">
                                <a class="btn btn-danger" href="pages.do?pageCount=3&pageNum=${num}">${num}</a>
                            </c:if>
                        </c:forEach>

                        <c:if test="${requestScope.pages.pageNum < requestScope.pages.totalPages }">
                            <a class="btn btn-danger" href="pages.do?pageCount=3&pageNum=${requestScope.pages.pageNum + 1}">下一页</a>
                        </c:if>

                        <c:if test="${requestScope.pages.pageNum == requestScope.pages.totalPages }">
                            <span class="btn btn-default disabled ">下一页</span>
                            <span class="btn btn-default disabled ">尾　页</span>
                        </c:if>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</body>
</html>
